//
//  ViewController.m
//  testpbl
//
//  Created by 黄权浩 on 15/8/3.
//  Copyright (c) 2015年 黄权浩. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:_textfield];
   //封装AFN
    [AFNetWorking afnetworkingPost:nil posturl:@"http://www.solecool.ru/app.php?root=getProductsList&type=onSaleList" changeDic:^(NSDictionary *dic) {
        NSLog(@"%@", dic);
    }];
    
    
//    模糊效果测试
//    [_testImg addSubview:[VisualEffectView initBlurEffectView:1 getsize:_testImg.bounds]];
//    ios7模糊效果测试
    [_testImg setImage:[[UIImage imageNamed:@"1.jpg"] applyBlurWithRadius:5 tintColor:[UIColor colorWithWhite:1 alpha:0.4] saturationDeltaFactor:1.8 maskImage:nil]];
 
    TopAlertViewVw *top = [[TopAlertViewVw alloc] initWithFrame:CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 64)];
    [self.view addSubview:top];
    //下载测试
//    [AFNetWorking sessionDownload:@"http://www.sneakerkicks.ru/images/sc.png"];
//    [AFNetWorking sessionDownload:@"http://www.sneakerkicks.ru/images/sc.png" backPath:^(NSURL *pathUrl) {
//        NSLog(@"%@", pathUrl);
//    }];
//    [AFNetWorking reach:^(int stateValue) {
//        NSLog(@"%d", stateValue);
//    }];
    
    //做c类跳转a类
    SecondViewController *sen = [[SecondViewController alloc] init];
    [sen changeString:^(NSString *str) {
        _testLabel.text = str;
    }];
}

//- (void)textFieldDidChange:(NSNotification *)obj
//{
//    UITextField * textField = (UITextField *)obj.object;
//    
//    NSString *toBeString = textField.text;
//    
//}
//
//- (void)dealloc
//{
//    [[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:_textfield];
//}

- (void)changeLabelDelegete:(NSString *)name
{
    _testLabel.text = name;
}

#define NMUBERS @"0123456789./*-+~!@#$%^&()_+-=,./;'[]{}:<>?`"
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSString *regex = @"[a-zA-Z0-9\u4e00-\u9fa5]*";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    NSLog(@"%@",textField.text);
    NSLog(@"%@",string);
    if(![pred evaluateWithObject:string])
    {
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"昵称只能由中文、字母或数字组成" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alertView show];
        return NO;
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)present:(id)sender {
//    [BlockClass changethetextName:^(NSString *str) {
//        _testLabel.text = str;
//    }];
    NSLockViewController *ding = [[NSLockViewController alloc] init];
    [self.navigationController pushViewController:ding animated:YES];
}
@end
